package com.ffyc.backserver.controller;

import com.ffyc.backserver.common.CommonResult;
import com.ffyc.backserver.model.Role;
import com.ffyc.backserver.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@RestController

@RequestMapping(path = "/api/Role")

public class RoleController {
    @Autowired
    RoleService roleService;
    @RequestMapping(value = "findRole")
    /*
    角色
     */
    public CommonResult findRole(){
        CommonResult commonResult=null;
        try {
           List<Role> roleList= roleService.findRole();
            if (roleList!=null){
                commonResult=new CommonResult<List<Role>>(200,"查询成功", roleList);
            }
            else {
                commonResult=new CommonResult<Role>(201,"查询失败",null);
            }
        }catch (Exception e){
            e.printStackTrace();
            commonResult=new CommonResult<Role>(500,"服务器错误",null);
        }

        return commonResult;
    }



}
